package com.controller;

import com.entity.Emp;
import com.until.Result;
import com.until.ResultStatus;

import javax.servlet.http.HttpSession;

public class BaseController {
    protected <T>Result success(T data){
        return new Result(ResultStatus.SUCCESS.getReturnCode(),
                ResultStatus.SUCCESS.getReturnMessage(),
                data);
    }

    protected <T>Result error(T data){
        return new Result(ResultStatus.ERROR.getReturnCode(),
                ResultStatus.ERROR.getReturnMessage(),
                data);
    }
    protected Emp getSession(HttpSession session) {
        Object empInfo = session.getAttribute("empInfo");
        if (empInfo instanceof Emp) {
            return (Emp) empInfo;
        }
        return null;
    }
}
